From: Jonas Dreßler Date: Mon, 11 May 2020 18:41:37 +0000 (+0200) Subject: st/theme: Remove entry from files_by_stylesheet after emitting signal X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~684^2^2~370 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=0f947d4ff99e220fbc91e64a10511f5ebc69d06e;p=gnome-shell.git st/theme: Remove entry from files_by_stylesheet after emitting signal Since e06109c23ce2a6dd53d32c26a89ab46a952d7373 we keep old theme nodes valid during the emission of the "custom-stylesheets-changed" signal. It turns out that we might still look up the file of a stylesheet using the files_by_stylesheet hashtable during the emission of that signal, causing a crash because the assertion in _st_theme_resolve_url() fails. So fix that and remove the stylesheet entry from the files_by_stylesheet hashtable after emitting the "custom-stylesheets-changed" signal. And to be consistent, also remove the entry from the stylesheets_by_file hashtable after emitting the signal. Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2757 --- diff --git a/src/st/st-theme.c b/src/st/st-theme.c index 7ccf7b5ba..3f08833a8 100644 --- a/src/st/st-theme.c +++ b/src/st/st-theme.c @@ -285,11 +285,15 @@ st_theme_unload_stylesheet (StTheme *theme, return; theme->custom_stylesheets = g_slist_remove (theme->custom_stylesheets, stylesheet); - g_hash_table_remove (theme->stylesheets_by_file, file); - g_hash_table_remove (theme->files_by_stylesheet, stylesheet); g_signal_emit (theme, signals[STYLESHEETS_CHANGED], 0); + /* We need to remove the entry from the hashtable after emitting the signal + * since we might still access the files_by_stylesheet hashtable in + * _st_theme_resolve_url() during the signal emission. + */ + g_hash_table_remove (theme->stylesheets_by_file, file); + g_hash_table_remove (theme->files_by_stylesheet, stylesheet); cr_stylesheet_unref (stylesheet); }